package com.longcai.cm.moudules.system.utils;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;


public class PasswordHelper {

    private static final String ALGORITH_NAME = "md5";

    private static final int HASH_ITERATIONS = 2;


    public static String encryptPassword(String password) {
        return new SimpleHash(ALGORITH_NAME, password,
                ByteSource.Util.bytes(password), HASH_ITERATIONS).toHex();
    }

//	public static String encryptPassword(SysUsers sysUsers) {
//		String newPassword = new SimpleHash(ALGORITH_NAME, sysUsers.getPassword(),
//				ByteSource.Util.bytes(sysUsers.getUsername()), HASH_ITERATIONS).toHex();
//		sysUsers.setPassword(newPassword);
//		return newPassword;
//	}

    public static void main(String[] args) {
        String s = PasswordHelper.encryptPassword("admin");
        System.out.println(s);
        System.out.println(ByteSource.Util.bytes("admin"));
    }
}